$(document).ready(function () {
    
        var $listgt=$(".list-group-item"),
            $listv=$(".list-view");

        function GetQueryString(name) {
           var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)","i");
           var r = window.location.search.substr(1).match(reg);
           if (r!=null) return (r[2]); return null;
        }
       
       var typeIndex=GetQueryString('type');
       $listgt.removeClass("active").eq(typeIndex).addClass("active");
       $listv.hide().eq(typeIndex).show();
});

//显示子菜单
function showSubMenus(subMenu){
	var subMenus = subMenu.split(":");
	var subMenuId = parseInt(subMenus[0]);
	if(subMenuId==0){
		$("#submenuId").attr("class","col-xs-3 col-xs-offset-1  col-sm-3 col-sm-offset-1 hidden");
	}else{
		 $.ajax({
            type: "get",//使用get方法访问后台
            dataType: "json",//返回json格式的数据
            url: "${pageContext.request.contextPath}/admin/menu_getSubMenus.action?parent_id="+subMenuId,//要访问的后台地址
            success: function(jsons){//msg为返回的数据，在这里做数据绑定
            	if(jsons.length>0){
            		$("#submenuId").attr("class","col-xs-3 col-xs-offset-1  col-sm-3 col-sm-offset-1 show");
            		$("#submenuId").empty();
	            	for(var i=0;i<jsons.length;i++){
	            		$("#submenuId").append("<option value="+jsons[i].id+":"+jsons[i].name+">"+jsons[i].name+"</option>");
	            	}
            	}else{
            		$("#submenuId").attr("class","col-xs-3 col-xs-offset-1  col-sm-3 col-sm-offset-1 hidden");
            	}
            	
            }
    	});
	}
	
}